package com.npy.reggie.doman;
import lombok.Data;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
@Data
public class R <E> implements Serializable {
    private Integer code;
    private String msg;
    private E data;
    
    private Map<String,Object> map = new HashMap<>();

    public static <E> R<E> success(E object){
        R<E> r = new R<>();
        r.code = 1 ;
        r.data= object;

        return r;
    }

    public static <E> R<E> error(String msg){
        R<E> r = new R<>();
        r.code = 0 ;
        r.msg = msg;

        return r;
    }
    public R<E> add(String key, Object value) {
        this.map.put(key, value);
        return this;
    }

}
